package com.hbnu.system.controller;

import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.OrganizationForm;
import com.hbnu.system.service.OrganizationFormService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/OrganizationForm")
@Api(tags = "纵向-组织形式模块")
public class OrganizationFormController {
    @Autowired
    private OrganizationFormService organizationFormService;

    @ApiOperation("组织形式添加")
    @PostMapping("/addorganizationFormService")
    public Rest<Boolean> addOrganizationForm(@RequestBody OrganizationForm organizationForm){
        boolean add = organizationFormService.addOrganizationForm(organizationForm);
        return add ? Rest.success():Rest.failed();
    }

    @ApiOperation("获取组织形式列表")
    @GetMapping("/getOrganizationForm")
    public Rest<List<OrganizationForm>> getActivityTypes(){
        List<OrganizationForm> projectcateList = organizationFormService.getOrganizationFormList();
        return Rest.success(projectcateList);
    }

    @ApiOperation("组织形式-修改")
    @PostMapping("/updateOrganizationForm")
    public Rest<Boolean> updateOrganizationForm(@RequestBody OrganizationForm organizationForm){
        boolean update = organizationFormService.updateOrganizationForm(organizationForm);
        return update ? Rest.success() : Rest.failed();
    }

    @ApiOperation("组织形式-删除")
    @GetMapping("/deleteOrganizationForm")
    public Rest<Boolean> deleteOrganizationForm(String ID){
        boolean delete = organizationFormService.deleteOrganizationForm(ID);
        return delete ? Rest.success() : Rest.failed();
    }

    @ApiOperation("组织形式-查询")
    @GetMapping("/selectOrganizationForm")
    public Rest<List<OrganizationForm>> selectOrganizationForm(String OrganizationFormName){
        List<OrganizationForm> organizationForm = organizationFormService.getByOrganizationFormName(OrganizationFormName);
        return Rest.success(organizationForm);
    }

}
